//
//  UMPushBean.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/3/15.
//

import Foundation
class UMPushIOSBean : Codable {
    var appkey = "67f3cdb4b8cd000d2c2b920b" ////ios key
    var timestamp : Int64 = 0
    var type = "customizedcast" //unicast单播   broadcast//广播  ，customizedcast别名推送
    var alias_type = "自定义类型"
    var production_mode = !isDebug
    
    var payload : Payload
    var alias : String
    var description : String
    
    init(timestamp: Int64, alias: String, title: String, content: String) {
        payload = Payload(title: title, text: content)
        self.timestamp = timestamp
        self.description = content
        self.alias = alias
    }
    
    class Payload : Codable {
        
        init(title : String, text: String) {
            self.aps = APS(title: title, text: text)
        }
        
//        var display_type = "notification"
        var aps : APS
        
        struct APS: Codable {
//            var contentAvailable: Int = 1  // 后台唤醒, Swift 属性名用驼峰命名
            var sound = "default"
            var alert: Alert?
            
            init(title: String, text: String) {
                self.alert = Alert(title: title,subtitle: text)
            }
            
            // 自定义 CodingKeys 映射到 JSON 字段名
            enum CodingKeys: String, CodingKey {
//                case contentAvailable = "content-available"  // 🔑 关键映射
                case alert
                case sound
            }
            
            struct Alert: Codable {
                var title: String?
                var subtitle: String?
//                var body: String?
            }
        }
    }
}
